home *** CD-ROM | disk | FTP | other *** search
- Imports StormSource.Gps
-
- Public Class EditWaypointForm
-
- Private pWaypoint As Waypoint
-
- ' Returns/sets the waypoint being edited by this form
- Public Property Waypoint() As Waypoint
- Get
- Return pWaypoint
- End Get
- Set(ByVal Value As Waypoint)
- ' Remember the waypoint for editing later on
- pWaypoint = Value
-
- ' Update the form with the values
- WaypointName.Text = pWaypoint.Name
- Position.Text = pWaypoint.ToString
- Description.Text = pWaypoint.Description
- Facility.Text = pWaypoint.Facility
- Address.Text = pWaypoint.Address
- City.Text = pWaypoint.City
- State.Text = pWaypoint.State
- Country.Text = pWaypoint.Country
- IntersectingRoad.Text = pWaypoint.IntersectingRoad
-
- ' Update the altitude depth. Are we using the Imperial or Metric system?
- If System.Globalization.RegionInfo.CurrentRegion.IsMetric Then
- ' Yes. Use meters
- Altitude.Text = pWaypoint.Altitude.ToMeters.ToString
- Else
- ' No. Use feet
- Altitude.Text = pWaypoint.Altitude.ToFeet.ToString
- End If
-
- ' Update the waypoint depth. Are we using the Imperial or Metric system?
- If System.Globalization.RegionInfo.CurrentRegion.IsMetric Then
- ' Yes. Use meters
- Depth.Text = pWaypoint.Depth.ToMeters.ToString
- Else
- ' No. Use feet
- Depth.Text = pWaypoint.Depth.ToFeet.ToString
- End If
-
- ' Populate the combo box with the list of available waypoint symbols
- WaypointSymbolComboBox.Items.Clear()
- WaypointSymbolComboBox.Items.AddRange(pWaypoint.Device.GetSymbols)
-
- ' Set the selected item to that of the waypoint
- WaypointSymbolComboBox.SelectedIndex = WaypointSymbolComboBox.FindString(pWaypoint.Symbol.ToString)
-
- ' Populate the color combo box with the list of available waypoint symbols
- WaypointColorComboBox.Items.Clear()
- WaypointColorComboBox.Items.AddRange(pWaypoint.Device.GetColors)
-
- ' Set the selected item to that of the waypoint
- WaypointColorComboBox.SelectedIndex = WaypointColorComboBox.FindString(pWaypoint.Color.ToString)
-
- ' Populate the display mode box with the list of available waypoint symbols
- WaypointDisplayModeComboBox.Items.Clear()
- WaypointDisplayModeComboBox.Items.AddRange(pWaypoint.Device.GetDisplayModes)
-
- ' Set the selected item to that of the waypoint
- WaypointDisplayModeComboBox.SelectedIndex = WaypointDisplayModeComboBox.FindString(pWaypoint.DisplayMode.ToString)
-
- ' Now, enable/disable features based on the capabilities of the device
- Description.Enabled = pWaypoint.Device.SupportsWaypointComment
- Address.Enabled = pWaypoint.Device.SupportsWaypointAddress
- WaypointSymbolComboBox.Enabled = pWaypoint.Device.SupportsWaypointSymbol
- WaypointColorComboBox.Enabled = pWaypoint.Device.SupportsWaypointColor
- WaypointDisplayModeComboBox.Enabled = pWaypoint.Device.SupportsWaypointDisplayMode
- Facility.Enabled = pWaypoint.Device.SupportsWaypointFacility
- Address.Enabled = pWaypoint.Device.SupportsWaypointAddress
- City.Enabled = pWaypoint.Device.SupportsWaypointCity
- State.Enabled = pWaypoint.Device.SupportsWaypointState
- Country.Enabled = pWaypoint.Device.SupportsWaypointCountry
- IntersectingRoad.Enabled = pWaypoint.Device.SupportsWaypointIntersectingRoad
- End Set
- End Property
-
- Private Sub SaveButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveButton.Click
- Try
- ' Update the waypoint with values from the form
- Waypoint.Name = Me.WaypointName.Text
- ' Update the position
- Dim NewPosition As Position = StormSource.Gps.Position.Parse(Position.Text)
- Waypoint.Latitude = NewPosition.Latitude
- Waypoint.Longitude = NewPosition.Longitude
- ' Update the comment
- Waypoint.Description = Me.Description.Text
- ' Update the symbol
- Waypoint.Symbol = System.Enum.Parse(GetType(WaypointSymbol), WaypointSymbolComboBox.Text)
- ' Update the color
- Waypoint.Color = System.Enum.Parse(GetType(WaypointColor), WaypointColorComboBox.Text)
- ' Update the symbol
- Waypoint.DisplayMode = System.Enum.Parse(GetType(WaypointDisplayMode), WaypointDisplayModeComboBox.Text)
- ' Update the altitude
- Dim NewAltitude As Distance = Distance.Parse(Me.Altitude.Text)
- Waypoint.Altitude = NewAltitude
- ' Update the depth
- Dim NewDepth As Distance = Distance.Parse(Me.Depth.Text)
- Waypoint.Depth = NewDepth
- ' Update the facility
- Waypoint.Facility = Me.Facility.Text
- ' Update the address
- Waypoint.Address = Me.Address.Text
- Waypoint.City = Me.City.Text
- Waypoint.State = Me.State.Text
- Waypoint.Country = Me.Country.Text
- ' Update the intersecting road/intersection
- Waypoint.IntersectingRoad = Me.IntersectingRoad.Text
- Catch ex As Exception
- ' Some error occurred while try to update waypoint information
- MessageBox.Show(ex.Message, "Form Information is Invalid", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
- Exit Sub
- End Try
- Try
- ' Save changes to this waypoint
- Waypoint.Save()
- ' Refresh the waypoints collection
- Waypoint.Device.Receiver.Waypoints.Refresh()
- ' Unload this form
- Close()
- Catch ex As Exception
- ' Notify of the problem saving the waypoint
- MessageBox.Show(ex.Message, "Unable to Save Waypoint", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
- Exit Sub
- End Try
- End Sub
-
- ' Raised when editing of a waypoint has been cancelled
- Private Sub CancelButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancelButton.Click
- Close()
- End Sub
- End Class
-